let s1 = 'ok'
console.log(s1, typeof s1)
let s2 = "ok"
//模板字符串
let s3 = `${s1} - ${s2}`
let s4 = `
id 100,
name lisi,
add 河南省
`
console.log(s2)
console.log(s3)
console.log(s4)
console.log('hello'.toUpperCase().toUpperCase().length)
console.log('*'.repeat(16))

let sp = 20
for (let i = 1; i <= 20; i += 2) {
    console.log(`${' '.repeat(--sp)}${'*'.repeat(i)}`)
}

let s5 = String('hello')
let s6 = String('hello')
//includes() 判断有没有相关的子串
console.log(s5.includes('he'));
console.log(s5 == s6, s5 === s6)
console.log(2 == 2, 2 === 2)
console.log(2 == '2', 2 === '2')

console.log('       hello      java      '.trim())
console.log('       hello      java      '.trim().replace(' ', ''))
console.log('       hello      java      '.trim().replaceAll(' ', ''))
console.log('hello'[0]);

//字符串连接
console.log(2 + 'ok', '2'.concat('ok'))

//将字符串splite 分为char数组 数组有reverse()方法，有join('')方法;
console.log('hello'.split('').reverse().join(''));
let ss = '李四 张三   李丽'.split(/ +/)
console.log('------------------')
console.log(ss, ss.length, ss.join(), ss.join('-'), ss.join(''))

//字符串转数字 string 2 number parseInt() parseFloat()
let ns = '100'
console.log(ns, typeof ns)

console.log(ns + 2, ns.concat(2), parseInt(ns) + 2, parseFloat(ns) + .5)

console.log(parseFloat(parseFloat('3.1415926').toFixed(3)));

//数字转字符串number 2 string
console.log(2, 2 + '')
console.log(2, Number(2).toString())


//字符串转日期时间
let d1 = '2023-03-30 16:56:50'
let cc = {year: 2023, month: 3 - 1, date: 30, hours: 16, minutes: 56, seconds: 50}
let d = new Date()
d.setFullYear(cc.year)
d.setMonth(cc.month)
d.setDate(cc.date)
d.setHours(cc.hours)
d.setMinutes(cc.minutes)
d.setSeconds(cc.seconds)
console.log(d.toLocaleString())

function strToDate(d1) {
    let ds = d1.split(/[- :]/).map(e => parseInt(e))
    console.log(ds)
    let d2 = new Date(...ds)
    d2.setMonth(d2.getMonth() - 1)
    return d2
//console.log(d2.toLocaleString())
}

console.log(strToDate(d1))
console.log(strToDate('1983-5-15 18:20:30').toLocaleString())





